package thirdlyHomework;

import java.util.Scanner;

public class verifictionCode {
    public static void main(String[] args) {
        method2 mt1 = new method2();
        Scanner sc = new Scanner(System.in);
        System.out.println("验证码为：" + mt1.getStr());
        System.out.println("请输入验证码：" + "\n");

        char[] b = new char[5];
        StringBuilder sb = new StringBuilder();

        // 循环5次，随机5个字符
        for (int i = 0; i < b.length; i++) {
            // 0 ~ 数组长度-1
            // 随机获取索引的值
            int index = sc.nextInt(b.length);
            char c = b[index];

            // 添加到sb中
            sb.append(c);
        }
        if (b.equals(mt1)) {
            System.out.print("验证成功");
        } else {
            System.out.println("请重新输入：");
        }
    }
}
